package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.FkwzQuestionT;
import com.ruoyi.system.service.IFkwzQuestionTService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 目标单位检查项问卷Controller
 * 
 * @author ruoyi
 * @date 2024-06-12
 */
@RestController
@RequestMapping("/question")
public class FkwzQuestionTController extends BaseController
{
    @Autowired
    private IFkwzQuestionTService fkwzQuestionTService;

    /**
     * 查询目标单位检查项问卷列表
     */
    @RequiresPermissions("system:t:list")
    @GetMapping("/list")
    public TableDataInfo list(FkwzQuestionT fkwzQuestionT)
    {
        startPage();
        List<FkwzQuestionT> list = fkwzQuestionTService.selectFkwzQuestionTList(fkwzQuestionT);
        return getDataTable(list);
    }

    /**
     * 导出目标单位检查项问卷列表
     */
    @RequiresPermissions("system:t:export")
    @Log(title = "目标单位检查项问卷", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FkwzQuestionT fkwzQuestionT)
    {
        List<FkwzQuestionT> list = fkwzQuestionTService.selectFkwzQuestionTList(fkwzQuestionT);
        ExcelUtil<FkwzQuestionT> util = new ExcelUtil<FkwzQuestionT>(FkwzQuestionT.class);
        util.exportExcel(response, list, "目标单位检查项问卷数据");
    }

    /**
     * 获取目标单位检查项问卷详细信息
     */
    @RequiresPermissions("system:t:query")
    @GetMapping(value = "/{questionId}")
    public AjaxResult getInfo(@PathVariable("questionId") Long questionId)
    {
        return AjaxResult.success(fkwzQuestionTService.selectFkwzQuestionTByQuestionId(questionId));
    }

    /**
     * 新增目标单位检查项问卷
     */
    @RequiresPermissions("system:t:add")
    @Log(title = "目标单位检查项问卷", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FkwzQuestionT fkwzQuestionT)
    {
        return toAjax(fkwzQuestionTService.insertFkwzQuestionT(fkwzQuestionT));
    }

    /**
     * 修改目标单位检查项问卷
     */
    @RequiresPermissions("system:t:edit")
    @Log(title = "目标单位检查项问卷", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FkwzQuestionT fkwzQuestionT)
    {
        return toAjax(fkwzQuestionTService.updateFkwzQuestionT(fkwzQuestionT));
    }

    /**
     * 删除目标单位检查项问卷
     */
    @RequiresPermissions("system:t:remove")
    @Log(title = "目标单位检查项问卷", businessType = BusinessType.DELETE)
	@DeleteMapping("/{questionIds}")
    public AjaxResult remove(@PathVariable Long[] questionIds)
    {
        return toAjax(fkwzQuestionTService.deleteFkwzQuestionTByQuestionIds(questionIds));
    }
}
